﻿/*  一、
*创建企业视图过程时
*添加了重大危险源视图
*代码如下：
*/ 
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'V' AND name = 'Enterprises_View')
BEGIN
	DROP  View Enterprises_View
END
GO
CREATE View Enterprises_View AS
SELECT EnterpriseID,EnterpriseName,Addess,Location,'150002'EnterpriseKind FROM ChemicalEnterprise
  UNION
SELECT EnterpriseID,EnterpriseName,Addess,Location,'150007'EnterpriseKind FROM CommercialEnterprise
  UNION
SELECT EnterpriseID,EnterpriseName,MineLocation Addess,Location,'150004'EnterpriseKind FROM CoalMineEnterprise
  UNION
SELECT EnterpriseID,EnterpriseName,Addess,Location,'150006'EnterpriseKind FROM ConstructionEnterprise
  UNION
SELECT EnterpriseID,EnterpriseName,Addess,Location,'150003'EnterpriseKind  FROM FireworkEnterprise
  UNION
SELECT EnterpriseID,EnterpriseName,Addess,Location,'150005'EnterpriseKind FROM NonCoalMineEnterprise
  UNION
SELECT EnterpriseID,EnterpriseName,Addess,Location,'150008'EnterpriseKind FROM IndustrialEnterprise
  UNION
SELECT EntID EnterpriseID,EntName EnterpriseName,Addess,Region Location,'150001'EnterpriseKind FROM Hazard
GO


/*二、
*事故救援力量表结构创建
*/
if exists (select 1
            from  sysobjects
           where  id = object_id('dbo.Eaer_AccidentRescueForce')
            and   type = 'U')
   drop table dbo.Eaer_AccidentRescueForce
go

/*==============================================================*/
/* Table: Eaer_AccidentRescueForce                              */
/*==============================================================*/
create table dbo.Eaer_AccidentRescueForce (
   AccidentID           int                  not null,
   RescueID             int                  not null,
   RescueName           varchar(100)         null,
   MainDuty             varchar(100)         null,
   Department           varchar(100)         null,
   Principal            varchar(50)          null,
   LinkTel              varchar(30)          null,
   constraint PK_EAER_ACCIDENTRESCUEFORCE primary key (AccidentID, RescueID)
)
go

execute sp_addextendedproperty 'MS_Description', 
   '事故救援力量',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce'
go

execute sp_addextendedproperty 'MS_Description', 
   '事故编码',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'AccidentID'
go

execute sp_addextendedproperty 'MS_Description', 
   '救援力量编码',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'RescueID'
go

execute sp_addextendedproperty 'MS_Description', 
   '救援力量名称',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'RescueName'
go

execute sp_addextendedproperty 'MS_Description', 
   '主要任务',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'MainDuty'
go

execute sp_addextendedproperty 'MS_Description', 
   '所属单位',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'Department'
go

execute sp_addextendedproperty 'MS_Description', 
   '负责人',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'Principal'
go

execute sp_addextendedproperty 'MS_Description', 
   '联系电话',
   'user', 'dbo', 'table', 'Eaer_AccidentRescueForce', 'column', 'LinkTel'
go
